import psutil

# 获取进程列表
processes = psutil.process_iter()

# 找到要终止的进程
for process in processes:
    if process.name() == "python.exe":
        process.kill()